const seatingDao =require('../dao/seatingDao');

module.exports={
    //查询
    async Allseatings() {
      return await seatingDao.Allseating()
  },
     //选择位置、场次
     async checkInfo({scheduleId,seatId}) {
         let result=await seatingDao.queryToRepeats({scheduleId,seatId});
         if(result!=null){
            return({code:'0',msg:'座位已被选'}) 
         }else{
            await seatingDao.seatingData({scheduleId,seatId});
            return ({code:'1',msg:'座位可选'})
         }
    } ,
    //修改位置、场次
    async modifyOptions({'_id':seatingId},{scheduleId,seatId}) {
     return await seatingDao.modifySeating({'_id':seatingId},{scheduleId,seatId})
   } ,
    //删除位置、场次
    async deleteSelectedSeating(seatingid) {
      return await seatingDao.deleteSeating({'_id':seatingid})
    } ,
    //查找详细信息
    async showSeatingDatail(seatingid) {
      return await seatingDao.showSeatingData(seatingid)
    } ,
      //分页
      async getAccessToPag({currentpage,pagesize}){
        //创建一个空对象
       let pagedata={};
       //当前页数
       pagedata.currentpage=currentpage;
        //每页显示的条数
       pagedata.pagesize=pagesize;
       //显示的数据
       pagedata.data=await seatingDao.accessToPag({currentpage,pagesize});
        //总条数
       pagedata.totalInt=await seatingDao.getsNumber();
       //总页数
       pagedata.totalSize=Math.ceil( pagedata.totalInt/pagesize);
       return pagedata
    },
}